home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DOS.SWG / 0084_Valid DOS Filename.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  810b  |  41 lines

  1. {
  2. > What are the valid characters for a filename in DOS?
  3.  
  4. Better to say which are invalid, or even more good to post a routine that
  5. checks filename for bad characters, eh? :)
  6. }
  7.  
  8. Function ValidFileName(FileName : string) : boolean; assembler;
  9. const BadChars : PChar = ' /,;^+[]"=*?|<>';  { these are BAD onez }
  10. Asm
  11.   mov dl,True
  12.   push ds
  13.   lds si,FileName
  14.   cld
  15.   lodsb
  16.   xor cx,cx
  17.   mov cl,al
  18.   jcxz @@4
  19. @@1:
  20.   lodsb
  21.   push ds
  22.   push cx
  23.   mov cx,15
  24.   lds di,BadChars
  25. @@2:
  26.   scasb
  27.   jnz @@3 { if not bad char then exec loop }
  28.   pop cx  { restore CX }
  29.   pop ds  { restore DS }
  30.   dec dl  { dl=False }
  31.   jmp @@4
  32. @@3:
  33.   loop @@3
  34.   pop cx  { restore CX }
  35.   pop ds  { restore DS }
  36.   loop @@1
  37. @@4:
  38.   pop ds
  39.   mov al,dl { result 0/1 (False/True) in AL }
  40. End; { ValidFileName }
  41.